export default class StringUtil {
    static is: any;
    public static format(pattern: string, params: any[]) {
        return pattern.format(pattern, params);
    }

    public static isEmpty(str: string) {
        return str.isEmpty();
    }

    public static replaceAll(str , replaceKey , replaceVal){
        var reg = new RegExp(replaceKey , 'g');//g就是代表全部
        return str.replace(reg , replaceVal || '');
    }
}

String.prototype.format = function (pattern: string, params: any[]) {
    let str = pattern;
    for (let k in params) {
        str = str.replace("\{\}", params[k])
    }
    return str;
}

String.prototype.isEmpty = function () {
    if (undefined == typeof (this) || null == this || this.length == 0) {
        return true;
    }
    return false;
}
